package map;

import java.util.HashMap;
import java.util.Map;

/**
 * 统计一个字符串中相同字符出现的次数
 */
public class Test {
    public static void main(String[] args) {
        String line = "i love java thinking in jaba!! hello world!" ;
        Map<Character,Integer>map = new HashMap<>();
        //遍历每一个字符串中的字符
        for (int i = 0; i < line.length(); i++) {
            char s = line.charAt(i);
            if (map.containsKey(line.charAt(i))){
                int num = map.get(s);
                num++;
                map.put(s,num);
            }else {
                map.put(s,1);
            }
        }
    }
}
